package hu.myandroidlife.activity;

import hu.myandroidlife.R;
import hu.myandroidlife.R.id;
import hu.myandroidlife.R.layout;
import hu.myandroidlife.base.BaseActivity;
import android.app.Activity;
import android.os.Bundle;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;

/**
 * 需求/目的：方便后续用到相关代码直接参考使用；
 * 难点：
 * 知识点：
 * 解决：
 */
public class EditTextMonitorActivity extends BaseActivity {
	
	private EditText etInput;
	private TextView tvShowLetterNum;

	@Override
	protected int getLayoutId() {
		return R.layout.activity_edit_text_monitor;
	}

	@Override
	protected void initView() {
		etInput=$findViewById(R.id.etInput);
		tvShowLetterNum=$findViewById(R.id.tvShowLetterNum);
	}

	@Override
	protected void initListener() {
		etInput.addTextChangedListener(new TextWatcher() {
			
			@Override
			public void onTextChanged(CharSequence s, int start, int before, int count) {
				tvShowLetterNum.setText(count+"");
			}
			
			@Override
			public void beforeTextChanged(CharSequence s, int start, int count,
					int after) {
				
			}
			
			@Override
			public void afterTextChanged(Editable s) {
				if(s.length()>0){
					tvShowLetterNum.setText(s.length()+"");
				}
			}
		});
	}

	@Override
	protected void widgetClick(View v) {
		
	}

}
